package com.gongye.courseselectionsystem.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author baorongchuan
 */
@Configuration
public class RabbitmqConfig {
    /**
     * 配置一个direct类型的交换机
     */
    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("myDirectExchange");
    }

    /**
     * 配置一个队列
     */
    @Bean
    public Queue directQueue() {
        return new Queue("myDirectQueue");
    }


    /**
     * 一个队列的交换机的绑定
     */

    @Bean
    public Binding directBinding(Queue directQueue, DirectExchange directExchange) {
        return BindingBuilder.bind(directQueue).to(directExchange).with("myDirectRoutingKey");
    }
}